{% extends "base.html" %}

{% block content %}
<div class="jumbotron">
	<div class="container">
        <h1><b>{{ 'Scoreboard' if en else '计分板' }}</b></h1>
	</div>
</div>
<div class="container">
	{% include "components/errors.html" %}

	{% if standings %}
    <div id="score-graph" class="row d-flex align-items-center">
        <div class="col-md-12 text-center">
            <i class="fas fa-circle-notch fa-spin fa-3x fa-fw spinner"></i>
        </div>
    </div>

	<div id="scoreboard" class="row">
		<div class="col-md-12">
			<table class="table table-striped">
				<thead>
					<tr>
                        {% if en %}
                        <td scope="col" style="text-align: center;width: 80px;"><b>Place</b></td>
                        {% if get_config('user_mode') == 'teams' %}
                        <td scope="col"><b>Team</b></td>
                        {% else %}
                        <td scope="col"><b>User</b></td>
                        {% endif %}
                        <td scope="col"><b>Score</b></td>
                        {% else %}
                        <td scope="col" style="text-align: center;width: 80px;"><b>名次</b></td>
                        {% if get_config('user_mode') == 'teams' %}
                        <td scope="col"><b>队伍</b></td>
                        {% else %}
                        <td scope="col"><b>用户</b></td>
                        {% endif %}
                        <td scope="col"><b>得分</b></td>
                        {% endif %}
					</tr>
				</thead>
				<tbody>
                {% cache 60, CacheKeys.PUBLIC_SCOREBOARD_TABLE %}
				{% for standing in standings %}
					<tr>
						<th scope="row" class="text-center">{{ loop.index }}</th>
						<td>
							<a href="{{ generate_account_url(standing.account_id) }}">
								{{ standing.name | truncate(50) }}

								{% if standing.oauth_id %}
									{% if Configs.user_mode == 'teams' %}
									<a href="https://majorleaguecyber.org/t/{{ standing.name }}">
										<span class="badge badge-primary">Official</span>
									</a>
									{% elif Configs.user_mode == 'users' %}
									<a href="https://majorleaguecyber.org/u/{{ standing.name }}">
										<span class="badge badge-primary">Official</span>
									</a>
									{% endif %}
								{% endif %}
							</a>
						</td>
						<td>{{ standing.score }}</td>
					</tr>
				{% endfor %}
                {% endcache %}
				</tbody>
			</table>
		</div>
	</div>
	{% endif %}
</div>
{% endblock %}

{% block scripts %}
	<script defer src="{{ url_for('views.themes', path='js/echarts.bundle.js') }}"></script>
{% endblock %}

{% block entrypoint %}
	<script defer src="{{ url_for('views.themes', path='js/pages/scoreboard.js') }}"></script>
{% endblock %}
